home *** CD-ROM | disk | FTP | other *** search
/ My Neighborhood / My Neighborhood.iso / mac / MacFiles / Shared.Dir / 00930.ls < prev    next >
Encoding:
Text File  |  1997-11-20  |  6.5 KB  |  178 lines

  1. on RandomizeAfterTwo
  2.   global ReqPetStore, ReqMovies, ReqGrocery, ReqDrugstore, ReqDrycleaners, ReqFarm, ReqZoo, ReqGrandma, ReqSchool, ReqPark, ReqPolice, ReqAirport, RewPetStore, RewMovies, RewGrocery, RewDrugStore, RewDryCleaners, RewFarm, RewZoo, RewGrandMa, RewSchool, RewPark, RewPolice, RewAirport, LocRew, LocReq, Locations, rewardLocs, requestLocs, AvailableLocRew, AvailableLocReq, NewCity, Loc1Name, Loc2Name, loc1Rew, Loc2Rew, HIDELOC, dummyList, availableLocs, calculatedLocs
  3.   if not calculatedLocs then
  4.     set HIGHLINKLOC to EMPTY
  5.     set HIDELOC to EMPTY
  6.     set highlink to 0
  7.     set calculatedLocs to 1
  8.     set AvailableLocRew to LocRew
  9.     set AvailableLocReq to LocReq
  10.     set NewCity to []
  11.     set rewardLocs to []
  12.     set requestLocs to []
  13.     set G to 0
  14.     repeat with d = 1 to 3
  15.       set escapecounter to 0
  16.       set G to G + 1
  17.       if d = 3 then
  18.         set tempcount to count(availableLocs)
  19.         set rnum to random(tempcount)
  20.         set RandLoc to getAt(availableLocs, rnum)
  21.       else
  22.         if d = 1 then
  23.           set rnum to getOne(availableLocs, Loc1Name)
  24.           set RandLoc to getAt(availableLocs, rnum)
  25.           set RandRew to loc1Rew
  26.         else
  27.           if d = 2 then
  28.             set rnum to getOne(availableLocs, Loc2Name)
  29.             set RandLoc to getAt(availableLocs, rnum)
  30.             set RandRew to Loc2Rew
  31.           end if
  32.         end if
  33.       end if
  34.       deleteAt(availableLocs, rnum)
  35.       setAt(NewCity, G, RandLoc)
  36.       set RewardList to getAt(AvailableLocRew, rnum)
  37.       set RequestList to getAt(AvailableLocReq, rnum)
  38.       deleteAt(AvailableLocRew, rnum)
  39.       deleteAt(AvailableLocReq, rnum)
  40.       if d = 3 then
  41.         set valid to 0
  42.         repeat while not valid
  43.           set tempcount to count(RewardList)
  44.           set rnum to random(tempcount)
  45.           set RandRew to getAt(RewardList, rnum)
  46.           set good to 1
  47.           repeat with W = 1 to count(rewardLocs)
  48.             if getAt(rewardLocs, W) = RandRew then
  49.               set good to 0
  50.             end if
  51.           end repeat
  52.           if good then
  53.             set valid to 1
  54.           end if
  55.         end repeat
  56.       end if
  57.       setAt(rewardLocs, G, RandRew)
  58.       setAt(requestLocs, G, EMPTY)
  59.       repeat with y = 1 to 2
  60.         set G to G + 1
  61.         set LinkFound to 0
  62.         repeat while not LinkFound
  63.           set tempcount to count(availableLocs)
  64.           set rnum to random(tempcount)
  65.           set RandLoc to getAt(availableLocs, rnum)
  66.           set RewardList to getAt(AvailableLocRew, rnum)
  67.           set RequestList to getAt(AvailableLocReq, rnum)
  68.           set escapecounter to escapecounter + 1
  69.           set ListCount to count(RequestList)
  70.           set keepLooking to 1
  71.           repeat with T = 1 to ListCount
  72.             if keepLooking then
  73.               set tempReq to getAt(RequestList, T)
  74.               if (tempReq = RandRew) or (escapecounter >= 40) then
  75.                 if ((d = 1) and (Loc2Name <> RandLoc)) or ((d = 2) and (Loc1Name <> RandLoc)) or (d = 3) then
  76.                   set LinkFound to 1
  77.                   setAt(NewCity, G, RandLoc)
  78.                   set rchange to 0
  79.                   if y >= highlink then
  80.                     set highlink to y
  81.                     set tempnLoc to HIDELOC
  82.                     set HIDELOC to RandLoc
  83.                     set rchange to 1
  84.                   end if
  85.                   setAt(requestLocs, G, tempReq)
  86.                   if escapecounter >= 40 then
  87.                     if rchange then
  88.                       set highlink to highlink - 1
  89.                       set HIDELOC to tempnLoc
  90.                     end if
  91.                     setAt(requestLocs, G, EMPTY)
  92.                   end if
  93.                   set tempcount to count(RewardList)
  94.                   set valid to 0
  95.                   repeat while valid = 0
  96.                     set newnum to random(tempcount)
  97.                     set RandRew to getAt(RewardList, newnum)
  98.                     if RandRew <> tempReq then
  99.                       set valid to 1
  100.                       setAt(rewardLocs, G, RandRew)
  101.                       set keepLooking to 0
  102.                       deleteAt(availableLocs, rnum)
  103.                       deleteAt(AvailableLocRew, rnum)
  104.                       deleteAt(AvailableLocReq, rnum)
  105.                     end if
  106.                   end repeat
  107.                 end if
  108.               end if
  109.             end if
  110.           end repeat
  111.         end repeat
  112.       end repeat
  113.     end repeat
  114.     set ACount to count(availableLocs)
  115.     repeat with T = 1 to ACount
  116.       set G to G + 1
  117.       set tempcount to count(availableLocs)
  118.       set rnum to random(tempcount)
  119.       set RandLoc to getAt(availableLocs, rnum)
  120.       deleteAt(availableLocs, rnum)
  121.       setAt(NewCity, G, RandLoc)
  122.       set RewardList to getAt(AvailableLocRew, rnum)
  123.       set RequestList to getAt(AvailableLocReq, rnum)
  124.       deleteAt(AvailableLocRew, rnum)
  125.       deleteAt(AvailableLocReq, rnum)
  126.       set tempcount to count(RewardList)
  127.       set cnt2 to 0
  128.       set notGood to 1
  129.       repeat while notGood
  130.         set cnt2 to cnt2 + 1
  131.         set rnum to random(tempcount)
  132.         set RandRew to getAt(RewardList, rnum)
  133.         set rewCount to 1
  134.         repeat with Z = 1 to count(rewardLocs)
  135.           set curRew to getAt(rewardLocs, Z)
  136.           if curRew = RandRew then
  137.             set rewCount to rewCount + 1
  138.           end if
  139.         end repeat
  140.         if (rewCount <= 2) and (cnt2 >= 20) then
  141.           setAt(rewardLocs, G, RandRew)
  142.           setAt(requestLocs, G, EMPTY)
  143.           set notGood to 0
  144.         end if
  145.       end repeat
  146.     end repeat
  147.     if HIDELOC = EMPTY then
  148.       repeat with HH = 1 to count(NewCity)
  149.         if getAt(NewCity, HH) <> EMPTY then
  150.           set HIDELOC to getAt(NewCity, HH)
  151.         end if
  152.       end repeat
  153.     end if
  154.     set dummyList to ["money", "newsPaper", "donut", "popcorn", "kite", "pencil", "aspirin", "ticket", "butter", "copPaper", "apron", "overalls", "balloons", "socks", "strawberries", "corn", "lollyPop", "shirt", "goldFish", "leash", "hat", "thermometer", "hay"]
  155.     repeat with T = 1 to count(requestLocs)
  156.       set hold1 to getAt(requestLocs, T)
  157.       if (hold1 <> EMPTY) and (hold1 <> " ") then
  158.         set temp to getOne(dummyList, hold1)
  159.         if temp <> 0 then
  160.           deleteAt(dummyList, temp)
  161.         end if
  162.       end if
  163.     end repeat
  164.   end if
  165.   set f to getOne(NewCity, Loc1Name)
  166.   setAt(rewardLocs, f, EMPTY)
  167.   set f to getOne(NewCity, Loc2Name)
  168.   setAt(rewardLocs, f, EMPTY)
  169. end
  170.  
  171. on showdata
  172.   global requestLocs, rewardLocs, NewCity, HIDELOC
  173.   put "rewardLocs = " & rewardLocs
  174.   put "requestLocs = " & requestLocs
  175.   put "newCity = " & NewCity
  176.   put "hiding at " & HIDELOC
  177. end
  178.